/*
 * Copyright (C) 2008 GeoScheduler Team, as stated on <http://www.geoscheduler.org/authors>.
 * 
 * This file is part of GeoScheduler.
 * 
 * GeoScheduler is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GeoScheduler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with GeoScheduler. If not, see <http://www.gnu.org/licenses/>.
 */
package org.geoscheduler.android.activities;

import org.geoscheduler.android.R;
import org.geoscheduler.android.alerts.AlertHelper;
import org.geoscheduler.android.sync.SyncEventsHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

/**
 * Services starting activity.
 * 
 * It just starts or stops given services and shows proper Toast.
 *
 * @author srakyi
 */
public class ServicesStarter extends Activity {
	
	public static final String PAR_START = ".start";

	@Override
	protected void onStart() {
		super.onStart();
		
		Intent intent = getIntent();
		Bundle extras = intent.getExtras();
		
		if (extras.getBoolean(ServicesStarter.class.getName() + ServicesStarter.PAR_START, true)) {
			// start services
			
			AlertHelper.registerIntent(this);
	        SyncEventsHelper.registerIntent(this);
	        
	        Toast.makeText(this, R.string.services_msg_started_both, Toast.LENGTH_SHORT).show();
	        
	        finish();
		} else {
			// stop services
			
			AlertHelper.unregisterIntent(this);
	        SyncEventsHelper.unregisterIntent(this);
	        
	        Toast.makeText(this, R.string.services_msg_stopped_both, Toast.LENGTH_SHORT).show();
	        
	        finish();
		}
	}
	
}
